package com.kagu.wms.module;

import com.wowza.wms.amf.*;
import com.wowza.wms.application.*;
import com.wowza.wms.client.*;
import com.wowza.wms.module.*;
import com.wowza.wms.request.*;
import com.wowza.wms.stream.IMediaStream;
import com.wowza.wms.stream.livetranscoder.ILiveStreamTranscoderControl;

public class TranscoderControlModule extends ModuleBase {
	class TranscoderControl implements ILiveStreamTranscoderControl
	{
		public boolean isLiveStreamTranscode(String transcoder, IMediaStream stream)
		{

			String name = stream.getName();
			System.err.println("transcoded stream: "+name);
			
			if(name.contains("_")){
				System.err.println("isLiveStreamTranscode");
				return false;
			}
			
			return true;
		}
	}
	


	public void onAppStart(IApplicationInstance appInstance) {
		String fullname = appInstance.getApplication().getName() + "/"
				+ appInstance.getName();
		
		getLogger().info("onAppStart: " + fullname);
		
		appInstance.setLiveStreamTranscoderControl(new TranscoderControl());
	}

	public void onAppStop(IApplicationInstance appInstance) {
		String fullname = appInstance.getApplication().getName() + "/"
				+ appInstance.getName();
		getLogger().info("onAppStop: " + fullname);
	}

	public void onConnect(IClient client, RequestFunction function,
			AMFDataList params) {
		getLogger().info("onConnect: " + client.getClientId());
	}

	public void onConnectAccept(IClient client) {
		getLogger().info("onConnectAccept: " + client.getClientId());
	}

	public void onConnectReject(IClient client) {
		getLogger().info("onConnectReject: " + client.getClientId());
	}

	public void onDisconnect(IClient client) {
		getLogger().info("onDisconnect: " + client.getClientId());
	}

}
